home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9895 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: templar.fgi.net!bwendlin
  2. From: bwendlin@I_should_put_my_domain_in_etc_NNTP_INEWS_DOMAIN (Physics Lizard)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Handling complex numbers...
  5. Date: 14 Mar 1996 05:58:23 GMT
  6. Organization: FGInet, Inc., Springfield, IL
  7. Message-ID: <4i8chv$12a@grail.fgi.net>
  8. References: <4hi113$2i8k@mercury.cc.uottawa.ca> <larry_kearney-0803960747220001@amaryllisp1.appsig.com> <1996Mar11.204246.7444@nosc.mil>
  9. NNTP-Posting-Host: templar.fgi.net
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. John W. Herman inexplicably wrote:
  13. } larry_kearney@appsig.com (Larry Kearney) writes:
  14.  
  15. } >> Dear fellow netters,
  16. } >> 
  17. } >> Can someone kindly explain to me how to represent complex numbers in C?
  18. } >> I am writing a numerical method program to calculate the area under
  19. } >> a curve using Simpson's Rule.  The problem that I face right now is
  20. } >> the representation of "i" (where i^2 = -1) in my C program.
  21. } >> 
  22. } >> Here's a simple example of what I mean:
  23. } >>   
  24. } >>   _b
  25. } >>  |           
  26. } >>  | exp(ix) dx 
  27. } >> _|             
  28. } >> a
  29. } >> 
  30. } >> 
  31. } >> How do I implement this function exp(ix)?
  32. } >> 
  33. } >> I'm grateful for your help.
  34. } >> 
  35. } >> Charles Tran
  36. } >> -- 
  37. } >> Charles
  38.  
  39. You may be able to use the fact that exp(ix) = (cos(x) - i * sin(x))
  40. or something like that.  The formula might be similar.  THen
  41. you can use a structure to represent the real and imaginary parts of
  42. the function.  Like:  cos is the real, sin is the imaginary.
  43.  
  44. --
  45. Bill Wendling            bwendlin@fgi.net 
  46. GCS/M/S d s-:+ a? C++++$ UL++>++++ P+++>+++++ L+++>+++++ E--- W-- N++ !o
  47. !K w--- O M-- !V PS+++@ PE- Y !PGP t+++(*) 5-- X- R++ tv--- b+++ DI++++
  48. !D G+ e++>+++++ h(++) !r !y+
  49.